<template>
  <el-container>
    <!-- 侧边栏 -->
    <el-aside width="auto">
      <el-menu
        class="el-menu-vertical-demo"
        :router="true"
        :default-active="$route.path"
        :collapse="isCollapse"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b"
      >
        <el-avatar
          :src="require('@/assets/logo.png')"
          :style="isCollapse ? '' : 'width:80px;height:80px'"
          @click.native="handleGoHome"
        />

        <el-menu-item index="/scan">
          <i class="el-icon-folder-checked"></i>
          <span slot="title">文件扫描</span>
        </el-menu-item>
        <el-menu-item index="/hdrft">
          <i class="el-icon-data-analysis"></i>
          <span slot="title">文档处理</span>
        </el-menu-item>
        <el-menu-item index="/settings">
          <i class="el-icon-setting"></i>
          <span slot="title">文件设置</span>
        </el-menu-item>
        <el-menu-item index="/about">
          <i class="el-icon-help"></i>
          <span slot="title">关于软件</span>
        </el-menu-item>
      </el-menu>
    </el-aside>

    <!-- 右侧主体部分 -->
    <el-container>
      <el-page-header
        title="☰"
        @back="handMenuOpen"
        style="-webkit-app-region: drag"
      />
      <span class="winctl">
        <i id="close" class="controller el-icon-close" @click="handleClose"></i>
        <i id="minimize" class="controller el-icon-minus" @click="handleMinimize"></i>
      </span>
      <el-header>{{ this.$route.meta.title }}</el-header>
      <el-divider></el-divider>
      <el-main>
        <router-view></router-view>
      </el-main>
      <el-divider></el-divider>
      <el-footer height="20px">simbaba 2021/5/21</el-footer>
    </el-container>
  </el-container>
</template>

<script>
// @ is an alias to /src
export default {
  name: "Home",
  data() {
    return {
      isCollapse: true,
    };
  },
  methods: {
    handMenuOpen() {
      this.isCollapse = !this.isCollapse;
    },
    handleGoHome() {
      if (this.$router.history.current.path !== "/") {
        this.$router.push("/");
      }
    },
    handleClose() {
      console.log('win close');
      window.ipc.send('window-close');
    },
    handleMinimize() {
      window.ipc.send('window-min');
    }
  },
};
</script>

<style>
.el-header {
  color: #333;
  text-align: center;
  height: 30px !important;
  font-weight: bold;
}

.el-footer {
  color: lightgrey;
  font-size: x-small;
  text-align: right;
}

.el-page-header__title {
  color: darkgray;
}

.el-icon-back:before {
  content: "" !important;
}

.el-page-header__left::after {
  width: 0 !important;
}

.el-divider--horizontal {
  margin: 0 !important;
}

.el-aside {
  background-color: rgb(84, 92, 100);
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  color: #333;
  text-align: center;
  height: 280px;
  text-align: left;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-aside::-webkit-scrollbar {
  display: none;
}

.winctl {
  position: absolute;
  top: 10px;
  right: 10px;
}

#close {
  position: absolute;
  right: 10px;
}
#minimize {
  position: absolute;
  right: 40px;
}
</style>